import { setToken, setUserInfo } from "@/redux/modules/global/action";
import { Button } from "antd";
import { connect } from "react-redux";
import { useNavigate } from "react-router-dom";

interface LoginProps {
    setToken: typeof setToken;
    setUserInfo: typeof setUserInfo;
}
const Login = (props: LoginProps) => {
    const {setToken, setUserInfo} = props
    const navigate = useNavigate()

    //处理登录
    const handleLoginSubmit = () => {
        setToken('token')
        setUserInfo({
            username: 'anhuiqq'
        })
        navigate('/loading')
    }

    return ( 
        <>
            <Button type="primary" onClick={handleLoginSubmit}>Login</Button>
        </>
     );
}

// export default Login;
// 映射dispatch到props上    
const mapDispatchToProps = {
    setToken,
    setUserInfo}
export default connect(null, mapDispatchToProps)(Login);